package itsm.isperp.framework.data.mybatis.type;

import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import oracle.sql.TIMESTAMP;

import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;

/**
 * 
 * 
 * 
 * @author lizx
 * @date 2014-11-22
 * @since 1.0
 * 
 */
public class OracleTimestampHandler extends BaseTypeHandler<TIMESTAMP> {

	@Override
	public void setNonNullParameter(PreparedStatement ps, int i,
			TIMESTAMP parameter, JdbcType jdbcType) throws SQLException {
		ps.setTimestamp(i, parameter.timestampValue());
	}

	@Override
	public TIMESTAMP getNullableResult(ResultSet rs, String columnName)
			throws SQLException {

		return (TIMESTAMP) rs.getObject(columnName);

	}

	@Override
	public TIMESTAMP getNullableResult(ResultSet rs, int columnIndex)
			throws SQLException {
		return (TIMESTAMP) rs.getObject(columnIndex);

	}

	@Override
	public TIMESTAMP getNullableResult(CallableStatement cs, int columnIndex)
			throws SQLException {
		return (TIMESTAMP) cs.getObject(columnIndex);

	}
}
